package org.rency.common.trigger.schedule.repository;

import java.util.Date;
import java.util.List;

import org.rency.common.trigger.beans.TaskStatusEnum;

public interface DaemonTaskTriggerRepository {
	
	public void createTable();
	
	public List<DaemonTaskTriggerDO> loadAll();
	
	public List<DaemonTaskTriggerDO> loadTriggerByStatus(TaskStatusEnum status);
	
	public DaemonTaskTriggerDO find(Integer triggerId);
	
	public DaemonTaskTriggerDO find(String beanName);
	
	public boolean save(DaemonTaskTriggerDO entity);
	
	public boolean delete(Integer triggerId);
	
	public boolean delete(String beanName);
	
	public boolean updateNextFireById(Integer triggerId, Date nextFire);
	
	public boolean updatePreviousFireById(Integer triggerId, Date previousFire);
	
	public boolean updateFireById(Integer triggerId, Date previousFire, Date nextFire);
	
	public boolean updateStatusById(Integer triggerId, TaskStatusEnum newStatus,TaskStatusEnum oldStatus);
	
	public boolean updateStatusBulk(TaskStatusEnum newStatus,TaskStatusEnum oldStatus);
	
	public boolean updateStatusByName(String beanName, TaskStatusEnum newStatus,TaskStatusEnum oldStatus);
	
	public boolean updateMachineInfo(Integer triggerId,String hostName,String localAddr);
	
	public boolean updateStatusMachineFire(Integer triggerId,TaskStatusEnum newStatus,TaskStatusEnum oldStatus,String hostName,String localAddr,Date previousFire, Date nextFire);
	
	public boolean updateStatusMachineFire(String beanName,TaskStatusEnum newStatus,TaskStatusEnum oldStatus,String hostName,String localAddr,Date previousFire, Date nextFire);

	public boolean updateCronExpression(String beanName,String cronExpression);
	
	public boolean initStatus();
	
}
